package MyThread_demo.thread_kongzhi;

/**
 * @author ChenYongHao
 * @date 2023/4/28 13:52
 * @desc join演示：等待这个线程死亡才能执行其它线程
 */
class ThreadJoin extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(getName() + ":" + i);
        }
    }
}

public class ThreadJoin_demo {
    public static void main(String[] args) {
        ThreadJoin tj1 = new ThreadJoin();
        ThreadJoin tj2 = new ThreadJoin();
        ThreadJoin tj3 = new ThreadJoin();
        tj1.setName("曹操");
        tj2.setName("刘备");
        tj3.setName("孙权");
        tj1.start();
        try {
            tj1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        tj2.start();
        tj3.start();
    }
}
